package com.example.review;

import java.util.Scanner;

/**
 * @author 23333
 */ //求斐波那契 fibonacci sequence 数列第 n 项值，n 为用户输入的正整数
public class Fibonacci {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入斐波那契数列的n：");
        int n = scanner.nextInt();
        long res = fib(n);
        System.out.println("斐波那契数列第"+n+"项是："+res);

    }
    private static long fib(int n){
        if(n == 1 || n == 2){
            return 1;
        }else{
            return fib(n-1)+fib(n-2);
        }
    }
}
